package com.etl.dataflow.scheduler.admin.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.etl.dataflow.scheduler.admin.validation.Add;
import com.etl.dataflow.scheduler.admin.validation.Update;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;

/**
 * <p>
 * 任务运行记录
 * </p>
 *
 * @author dx
 * @since 2022-04-24
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("dataflow_task_record")
public class DataflowTaskRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 主键,使用ID_WORKER策略,全局唯一ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    @NotNull(groups = Update.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long id;

    /**
     * 任务信息id
     */
    @TableField("task_info_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long taskInfoId;

    /**
     * 执行器UUID
     */
    @TableField("executor_uuid")
    private String executorUuid;

    /**
     * 任务状态
     */
    @TableField("task_state")
    private Integer taskState;

    /**
     * 任务启动时间
     */
    @TableField("launch_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date launchTime;

    /**
     * 任务结束(出错)时间
     */
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    /**
     * 错误日志
     */
    @TableField("error_log")
    private String errorLog;

    /**
     * 创建用户id
     */
    @TableField("creator_id")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long creatorId;

    /**
     * 插入时间
     */
    @TableField(value = "idt", fill = FieldFill.INSERT)
    private LocalDateTime idt;

    /**
     * 更新时间
     */
    @TableField(value = "udt", fill = FieldFill.UPDATE)
    private LocalDateTime udt;


}
